#pragma once
#include <fstream>
#include <string.h>
using namespace std;
struct recipe{	//Aligns with Assets, Itemfiles, etc.

	bool  hasIngredients[4]; //If all four of these can be made, the item can be crafted.
	char* namIngredients[4]; //The names of the ingredients required. "NO_CRAFT" means cannot craft, "FREE" means one free craft spot.
	short itemType;			 //What type of object we're creating here.
	recipe()
	{
		for(int i = 0; i < 4; i++)
		{	
			hasIngredients[i] = false;
			namIngredients[i] = "false";
		}
	}

	void initRecipe(char* FileName)
	{
		ifstream File(FileName);
		if(File.is_open())
		{
			string trashData;
			string goodData;

			for(int i = 0; i < 4; i++)
			{
				getline(File,trashData,':');
				getline(File,goodData,';');
				namIngredients[i] = wordModify::copy(namIngredients[i],goodData);
			}
		}
	}


	bool checkIfUsesIngredientAt(char* IngredName, int index)
	{
		return(wordModify::compare(namIngredients[index], IngredName));
	}

	void checkIfUses(char* IngredName)
	{

		for(int i = 0; i < 4; i++)
		{
			if(IngredName != "NO_CRAFT" && !hasIngredients[i] )
			{
				if(wordModify::compare(namIngredients[i], IngredName)	
					||wordModify::compare(namIngredients[i], "FREE"))
				{
					hasIngredients[i] = true;
					return;
				}
			}//Endif
		}//Endfor
	}

	bool canBeCrafted()
	{
		for(int i = 0; i < 4; i++)
			if(hasIngredients[i] == false)
				return false;
		return true;
	}

	void clear()
	{
		for(int i = 0; i < 4; i++)
			hasIngredients[i] = false;
	}

};
